//
//  ViewController.m
//  CalenderDemo
//
//  Created by wr on 2018/7/20.
//  Copyright © 2018年 stzen. All rights reserved.
//

#import "ViewController.h"
#import "CalenderVC.h"
#import "CalenderManager.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 100, 50)];
    btn.layer.borderColor = [UIColor greenColor].CGColor;
    btn.layer.borderWidth = 3.f;
    [btn setTitle:[NSString stringWithFormat:@"%ld", (long)[CalenderManager currentDateCompoent].day] forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(showCalenderVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

}

- (void)showCalenderVC {
    CalenderVC * calenderVC = [[CalenderVC alloc] init];
    calenderVC.limitedMonth = 12 * 1;
    [self.navigationController pushViewController:calenderVC animated:YES];
//    [self presentViewController:calenderVC animated:YES completion:nil];
}

- (NSInteger)day:(NSDate *)date{
    NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:date];
    return [components day];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
